function setContent (sec,com,el,callback) {
	var url = base_url() + sec + '/' + com;
	$('#iframeContent').prop('src',url).load(function(){
		if(typeof callback == 'function')
		{
			callback(url);
		}
		try
		{
			$('#iframeContent').get(0).contentWindow.SetGridMainIcon($(el).find('>i').prop('class'));
		}
		catch(e){}
	});
}
function checkHash(){}


$(document).ready(function () {
 	var loggedIn = !($('#AppLoad').text().replace(/\s/,'') == 'Welcome'); 
	// INIT LAYOUT
	var west_not_loggedIn = {initClosed:true,togglerLength_closed:0,size:250};
	var west_loggedIn = {size:313};
	if(loggedIn){
		$('.userMenu').show().css({
			display: 'block',
			padding: '21px 9px 0 51px',
			position: 'absolute',
			right: '0',
			top: '0'
		});
		$('.userMenu button').css({padding:'4px',cursor:'pointer'}).addClass('ui-state-default ui-corner-all')

	}
	var westConfig = loggedIn ? west_loggedIn : west_not_loggedIn;
	$('body').layout({ 
		applyDemoStyles: false, 
		east:{initClosed:true,togglerLength_closed:0},
		north:{size:124,initClosed:0,togglerLength_open:0},
		south:{size:0,initClosed:1,togglerLength_open:0},
		west:westConfig,
		east__initHidden: true ,
		west__resizable: false,
		east__resizable: false,
		north__resizable: false,
		south__resizable: false,
	});

	// INIT SIDEBAR MENU
	$( "#accordion" ).accordion({
		heightStyle: "content",
		autoHeight: false,
        clearStyle: true, 
	});

 	$('a.um-chg-pwd').click(function(){

			var url = $(this).prop('href');
   			var dlg = $('<div id="upwdlg"></div>');
   			var cnt = '<div class="pengguna-password">'+
				'<div>'+
					'<label style="display: block; width: 87px; float: left; line-height: 22px;">Password :</label>'+
					'<input style="float:left;margin-top:1px;" type="password" name="pengguna_password"/>' +
				'</div><div><input  style="float:left;cursor:pointer;margin-left:2px" type="button" value="Set" class="cmd_set_passwd"/></div>' +
			'</div>';
			var dlg_title = 'Ubah Password  ';
			try{
			dlg.html(cnt).dialog({
				modal:true,
				title:dlg_title,
				width:328,
				height:80,
				close:function(){
					dlg.remove();
				}
			});
			
			dlg.find('input.cmd_set_passwd').click(function(){
				var new_passwd = dlg.find('input[name=pengguna_password]').val();
				if(!new_passwd.length){
					alert('Mohon lengkapi data Anda !')
					return;
				}

				
				$.post(url,{passwd:new_passwd},function(o){
					alert(o);
					dlg.dialog('close')	;
				});	
			})
			dlg.find('input[name=pengguna_password]').keydown(function(e){
				if(e.keyCode==13){
					dlg.find('input.cmd_set_passwd').click();
				}
			});
			dlg.dialog('open');
   			}
   			catch(e){
   				//console.log(e)
   			}
			return false;
    	});

	$('.user-menu .ui-accordion-header-icon.ui-icon.ui-icon-triangle-1-e').remove();	

	$(window).resize(function(){
		var lc = $('.ui-layout-center.ui-layout-pane.ui-layout-pane-center');
		setTimeout(function(){
			lc.height($(this).height()-122)
		},500);
	});
	setTimeout(function(){
		$(window).trigger('resize');
	},100);
});